from typing import Optional, List, Dict, Any
from pydantic import BaseModel, ConfigDict
from datetime import datetime

class WorkflowBase(BaseModel):
    name: str
    description: Optional[str] = None
    nodes: List[Dict[str, Any]]
    edges: List[Dict[str, Any]]

class WorkflowCreate(WorkflowBase):
    user_id: int

class WorkflowUpdate(WorkflowBase):
    pass

class WorkflowInDBBase(WorkflowBase):
    id: int
    user_id: int

    model_config = ConfigDict(from_attributes=True)

class Workflow(WorkflowInDBBase):
    created_at: datetime
    updated_at: Optional[datetime] = None

class WorkflowResponse(WorkflowInDBBase):
    created_at: datetime
    updated_at: Optional[datetime] = None

    model_config = ConfigDict(from_attributes=True) 